﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace aop_cache.Filters
{
    /// <summary>
    /// 自定义模板页面
    /// </summary>
    public class LayoutAttribute : ActionFilterAttribute
    {
        private readonly string _masterName;
        public LayoutAttribute(string masterName)
        {
            _masterName = masterName;
        }
        /// <summary>
        /// 页面渲染结束后执行
        /// </summary>
        /// <param name="filterContext"></param>
        public override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            base.OnActionExecuted(filterContext);
            var result = filterContext.Result as ViewResult;
            if (result != null)
            {
                result.MasterName = _masterName;
            }
        }
    }

}